const orderTypeEnum = {
	WAIT: {
		code: 1,
		msg: '待接单',
		title: '等待司机接单中',
		desc: '系统正在为您快速匹配附近司机'
	},
	GET: {
		code: 2,
		msg: '已接单',
		title: '司机已接单',
		desc: '司机正在快马加鞭赶来中'
	},
	WAITING: {
		code: 3,
		msg: '等待中',
		title: '司机等待中',
		desc: '司机已到达起点，等待出发'
	},
	START: {
		code: 4,
		msg: '服务中',
		title: '服务中',
		desc: '司机正在将您送往目的地'
	},
	PENDING_PAY: {
		code: 5,
		msg: '待支付',
		title: '',
		desc: ''
	},
	FINISH: {
		code: 6,
		msg: '已完成',
		title: '已完成',
		desc: '订单已完成'
	},
	REFUND_PENDING: {
		code: 7,
		msg: '待退款',
		title: '待退款',
		desc: '审核通过后金额将原路返还'
	},
	REFUNDED: {
		code: 8,
		msg: '已退款',
		title: '已退款',
		desc: '订单支付金额已原路返还'
	},
	REFUND_REFUSED: {
		code: 9,
		msg: '拒绝退款',
		title: '拒绝退款',
		desc: '客服审核失败，订单金额不予退还'
	},
	CANCEL: {
		code: 10,
		msg: '已取消',
		title: '订单已取消',
		desc: '您已取消订单'
	}
}

function getTypeNameByCode (code) {
	let res = null
	const typesKeys = Object.keys(orderTypeEnum)
	typesKeys.forEach(k => {
		if (orderTypeEnum[k].code === code) {
			res = orderTypeEnum[k].msg
		}
	})
	return res ? res : '未知的订单类型'
}

function getTitleOrDescByCode (code, propertyName) {
	let res = null
	const typesKeys = Object.keys(orderTypeEnum)
	typesKeys.forEach(k => {
		if (orderTypeEnum[k].code === code) {
			if (propertyName === 'title') {
				res = orderTypeEnum[k].title
			} else {
				res = orderTypeEnum[k].desc
			}
		}
	})
	return res ? res : ''
}

export {
	orderTypeEnum,
	getTypeNameByCode,
	getTitleOrDescByCode
}